package com.bawei.shopping2.viewmodel

import androidx.lifecycle.ViewModel
import com.bawei.shopping2.entity.BannerEntity
import com.bawei.shopping2.entity.CategoryEntity
import com.bawei.shopping2.entity.GoodsEntity
import com.bawei.shopping2.http.ApiResponse
import com.bawei.shopping2.repository.MainRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

//注意：依赖注入到viewModel
@HiltViewModel
class MainViewModel @Inject constructor(private var mainRepository: MainRepository):ViewModel() {
    suspend fun  banners(): ApiResponse<MutableList<BannerEntity>>{
       return mainRepository.banners()
    }
    //一级分类
    suspend fun mainCategory():ApiResponse<MutableList<CategoryEntity>>{
        return mainRepository.mainCategory()
    }
    //二级分类
    suspend fun category(parent_id:Int):ApiResponse<MutableList<CategoryEntity>>{
        return mainRepository.category(parent_id)
    }
    //商品信息
    suspend fun goods(category_id:Int, currentPage:Int, pageSize:Int):ApiResponse<MutableList<GoodsEntity>>{
        return mainRepository.goods(category_id,currentPage,pageSize)
    }


}